algorithm to find minimum and maximum elements using divide and conquer